<?php
	/**
	 * 背包列表
	 */
    class UsePropRecord extends APIBase {
		
		public $tag = "UsePropRecord";
    	public $isLogin = true;
		
		public function before() {
			$this->initCacheRedis();
			$this->initMysql();
			return true;
		}
		public function logic(){
			$playerID = $this->uid;
			$propid = $this->param['propid'];
			//背包列表
			$backpacklist = $this->cache_redis->keys("hbackpack:$playerID:*");
			for($i=0;$i<count($backpacklist);$i++){
				$list = $this->cache_redis->hGetAll("hbackpack:$playerID:".$i);
				if($list['propid']==$propid){
					if($list['type']==1){//使用房卡
					   // $cradlist = $this->data_redis->hMGet("hu:".$playerID,array("room_card","room_card_coop"));
						$num = (int)$list['count']-1;
						$this->cache_redis->hset("hbackpack:$playerID:".$i,"count",$num);
						if($list['propid']==1){//独立型房卡
							$this->data_redis->hset("hu:".$playerID,"room_card",$num);
						}elseif($list['propid']==2){//共付型房卡
							$this->data_redis->hset("hu:".$playerID,"room_card_coop",$num);
						}
					}
				}
			}


            
		}
		
        public function after() {
			$this->deinitCacheRedis();
		}
    }
?>
